import { computed, type ComputedRef, unref } from 'vue';
import type { BasicTableProps } from '../types/table';

export function useVxeColumns(propsRef: ComputedRef<BasicTableProps>) {
  const getColumnsRef = computed(() => {
    const { columns } = unref(propsRef);
    // handleIndexColumn(propsRef, getPaginationRef, columns)
    // handleActionColumn(propsRef, columns)
    if (!columns) {
      return [];
    }
    return columns;
  });
  return {
    getColumnsRef,
  };
}

export const setIndex = (reserveIndex: boolean, index: number, size: number, current: number) => {
  if (reserveIndex) {
    return size * (current - 1) + index;
  } else {
    return index;
  }
};
